setfenv(1, require'winapi')
require'winapi.class'
require'winapi.window'
require'winapi.wm'
require'winapi.icon'
require'winapi.imagelist'
require'winapi.router'

function ShowcaseWindow()
	local router = Router()
	local class = RegisterClass{name='ShowcaseWindow', proc = router.proc}
	local window = CreateWindow{caption = 'Showcase', class = class, w=700, h=500}
	router:add_handler('Window', window, WindowQuitHandler)
	UpdateWindow(window)
	ShowWindow(window, SW_SHOWNORMAL)
	return window, router
end

function ShowcaseImageList(w,h)
	local imagelist = ImageList_Create({w=w,h=h})
	local hmod = LoadLibrary'shell32'
	for i=1,10 do
		local hi = LoadIcon(hmod, i)
		ImageList_AddIcon(imagelist, hi)
	end
	return imagelist
end

if not ... then
local window, router = ShowcaseWindow()
local imagelist = ShowcaseImageList()
MessageLoop()
end
